package com.aaa.sbms.controller;

import com.aaa.sbms.service.LeaveService;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.Map;

@RestController
@RequestMapping("leave")
public class LeaveController {

    @Autowired(required = false)
    private LeaveService leaveService;

    /**
     * 查询部门
     * @return
     */
    @RequestMapping("depts")
    public Map depts(){
        return leaveService.depts();
    };

    /**
     * 分页查询请假申请（人事）
     * @param map
     * @return
     */
    @RequestMapping("personCheckPage")
    public Map personCheckPage(@RequestParam Map map){
        return leaveService.leavePage(map);
    };

    /**
     * 分页查询领导审核请假
     * @param map
     * @return
     */
    @RequestMapping("leaderCheckPage")
    public Map leaderCheckPage(@RequestParam Map map){
        return leaveService.leaderCheckPage(map);
    };

    /**
     * 分页查询请假审核记录
     * @param map
     * @return
     */
    @RequestMapping("checkLeavePage")
    public Map checkLeavePage(@RequestParam Map map){
        return leaveService.checkLeavePage(map);
    };

    /**
     * 查询一个请假申请
     * @return
     */
    @RequestMapping("leaveOne")
    public Object leaveOne(){
        return leaveService.leaveOne();
    }

    /**
     * 查询一个人事审核
     * @param id
     * @return
     */
    @RequestMapping("personCheckOne")
    public Map personCheckOne(Integer id){
        return leaveService.personCheckOne(id);
    };

    /**
     * 查询一个人事审核
     * @param id
     * @return
     */
    @RequestMapping("leaderCheckOne")
    public Map leaderCheckOne(Integer id){
        return leaveService.leaderCheckOne(id);
    };

    /**
     * 添加请假申请
     * @param map
     * @return
     */
    @RequestMapping("addLeave")
    public int addLeave(@RequestBody Map map){
        return leaveService.addLeave(map);
    };

    /**
     * 修改人事审核结果
     * @param map
     * @return
     */
    @RequestMapping("firstYes")
    public int firstYes(@RequestBody Map map){
        return leaveService.updateFirstCheck(map);
    };

    /**
     * 修改领导审核结果
     * @param map
     * @return
     */
    @RequestMapping("secondYes")
    public int secondYes(@RequestBody Map map){
        return leaveService.updateSecondCheck(map);
    };
}
